﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.Collections;

namespace WebVideo.Areas.Admin.Models
{
    public class ReportViewModel
    {
        public int Id { get; set; }
        public int IdVideo { get; set; }     
        public string UserName { get; set; }
        public int ViewExtend { get; set; }
        public DateTime? Date { get; set; }

        public static IEnumerable<EntityReport_View> Index()
        {
            dbVideoDataContext db = new dbVideoDataContext();
            var query = from p in db.EntityReport_Views
                        orderby p.Date descending
                        select p;
            return query.ToList();
        }
        public static void Ban(int Id, int l)
        {
            dbVideoDataContext db = new dbVideoDataContext();

            EntityReport_View tnew = db.EntityReport_Views.Where(p => p.Id == Id).Single();
            tnew.Status = l;
            db.SubmitChanges();

        }
        public static void Delete(int Id)
        {
            dbVideoDataContext db = new dbVideoDataContext();

            EntityReport_View faq = db.EntityReport_Views.Where(p => p.Id == Id).Single();
            db.EntityReport_Views.DeleteOnSubmit(faq);
            db.SubmitChanges();
        }      
    }
}